<?php

namespace common\models;

use Yii;
use yii\db\ActiveRecord;

/**
 * This is the model class for table "{{%auth_rule}}".
 *
 * @property integer $id
 * @property integer $pid
 * @property string $route
 * @property string $title
 * @property string $icon
 * @property integer $order
 * @property integer $is_show
 * @property integer $status
 */
class AuthRuleModel extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%auth_rule}}';
    }
    public function scenarios()
    {
        $scenarios = parent::scenarios();
        $scenarios[self::SCENARIO_CREATE] = ['pid', 'route', 'title', 'icon', 'status', 'is_show', 'order'];
        $scenarios[self::SCENARIO_UPDATE] = ['pid', 'route', 'title', 'icon',  'status', 'is_show', 'order'];
        return $scenarios;

    }
    public function attributeValues()
    {
        return [
            'type' => [
                '1' => '权限和菜单',
                '2' => '权限',
                '3' => '菜单',
            ],
            'status' => [
                0 => '关闭',
                1 => '开启'
            ],
            'is_show' => [
                0 => '隐藏',
                1 => '显示'
            ]
        ];


    }

    public function attributeLabels()
    {

        return [
            'id' => '主键',
            'pid' => '上级ID',
            'route' => '路由',
            'title' => '名称',
            'icon' => '图标',
            'status' => '状态',
            'is_show' => '显示',
            'order' => '排序',

        ];


    }

    public function rules()
    {
        return [
            ['pid', 'default', 'value' => '0'],
            ['route', 'required', 'message' => '路由必须'],
            ['title', 'required', 'message' => '名称必须'],
            [['icon'], 'string', 'max' => 255],
            [['order'], 'string', 'max' => 11],
            ['status', 'required', 'message' => '状态必须'],
            ['is_show', 'required', 'message' => '显示必须'],
        ];

    }
}
